package com.code.petapp.util;

/**
 * SharedPreferences操作类，保存共用参数
 * 里面所有的用户数据都是本地自行设置使用
 */

public class SPCommonUtils {

    private static final String TAG = "SPCommonUtils";

    private static SPCommonUtils mSPCommonUtils;

    private SPCommonUtils() {

    }

    public synchronized static SPCommonUtils getInstance() {
        synchronized (SPCommonUtils.class) {
            if (mSPCommonUtils == null) {
                mSPCommonUtils = new SPCommonUtils();
            }
        }
        return mSPCommonUtils;
    }

    public void Clear() {
        SPCommonBase.clear();
    }

    public void setToken(String token) {
        SPCommonBase.put("token", token);
    }

    public String getToken() {
        return (String) SPCommonBase.get("token", "");
    }

    public void setUserId(int userId) {
        SPCommonBase.put("user_id", userId);
    }

    public int getUserId() {
        return (int) SPCommonBase.get("user_id", 0);
    }

    public void setIsLogin(boolean isLogin){
        SPCommonBase.put("is_login", isLogin);
    }
    public boolean getIsLogin(){
        return (boolean) SPCommonBase.get("is_login", false);
    }

    public void setUserName(String userName){
        SPCommonBase.put("user_name", userName);
    }
    public String getUserName(){
        return (String) SPCommonBase.get("user_name", "");
    }

    public void setName(String name){
        SPCommonBase.put("name", name);
    }
    public String getName(){
        return (String) SPCommonBase.get("name", "");
    }

    public void setPassword(String password){
        SPCommonBase.put("password", password);
    }
    public String getPassword(){
        return (String) SPCommonBase.get("password", "");
    }

    public void setEmail(String email){
        SPCommonBase.put("email", email);
    }
    public String getEmail(){
        return (String) SPCommonBase.get("email", "");
    }

    public void setPhone(String phone){
        SPCommonBase.put("phone", phone);
    }
    public String getPhone(){
        return (String) SPCommonBase.get("phone", "");
    }

    public void setAddress(String address){
        SPCommonBase.put("address", address);
    }
}
